package report

import grails.test.*

class ActivityTests extends GrailsUnitTestCase {
	
	private String nature = "pesquisa"
	private String theme = "gatos egito"
	private String target = "alunos"
	private String type = "Ensino"
	private String description = "qualquer uma"
	private String reasons = "para aprender"
	private String expectedResults = "result a"
	private String actualResults = "result b"
	private String comments = "nenhum"
	private String partners = "nenhum"
	private Date startDate = new Date()
	private Date endDate = new Date()
	private int status = 1
	private Plan plan = new Plan(year:2010, observation:"nenhuma")
	
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testValues() {
		Activity a = new Activity(nature:nature, theme:theme, target:target, type:type,
				description:description, reasons:reasons, expectedResults:expectedResults, 
				actualResults:actualResults, comments:comments, partners:partners,
				startDate:startDate, endDate:endDate, status:status, plan:plan)
		assertEquals nature, a.nature
		assertEquals theme, a.theme
		assertEquals target, a.target
		assertEquals type, a.type
		assertEquals description, a.description
		assertEquals reasons, a.reasons
		assertEquals expectedResults, a.expectedResults
		assertEquals actualResults, a.actualResults
		assertEquals comments, a.comments
		assertEquals partners, a.partners
		assertEquals startDate, a.startDate
		assertEquals endDate, a.endDate
		assertEquals status, a.status
		assertEquals plan, a.plan
	}
    

	void testConstraints(){
		def a = new Activity(nature:nature, theme:theme, target:target, type:type,
				description:description, reasons:reasons, expectedResults:expectedResults, 
				actualResults:actualResults, comments:comments, partners:partners,
				startDate:startDate, endDate:endDate, status:status, plan:plan)
		
		mockForConstraintsTests(Activity,[a])
//		assertTrue a.validate()
 
		def t = new Activity()

		assertFalse t.validate() 
		assertEquals "nullable", t.errors["nature"] 
		assertEquals "nullable", t.errors["theme"]
		assertEquals "nullable", t.errors["type"]
		assertEquals "nullable", t.errors["months"]
		assertEquals "nullable", t.errors["startDate"]
		assertEquals "nullable", t.errors["endDate"]
		
	}
}
